<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="70px">
      <el-form-item label="公司名称" prop="companyName">
        <el-input
          v-model="queryParams.companyName"
          placeholder="请输入公司名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="APP名称" prop="appName">
        <el-input
          v-model="queryParams.appName"
          placeholder="请输入APP名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="时间" prop="cjDate">
        <el-date-picker clearable
                        v-model="queryParams.cjDate"
                        type="daterange"
                        style="width: 350px"
                        value-format="yyyy-MM-dd"
                        range-separator="-"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="yxsjList">
      <el-table-column label="序号" type="index" width="50" align="center">
        <template slot-scope="scope">
          <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
        </template>
      </el-table-column>
      <el-table-column label="公司名称" align="center" prop="companyName" />
      <el-table-column label="APP名称" align="center" prop="appName" />
<!--      <el-table-column label="APP包名" align="center" prop="packageName" />-->
      <el-table-column label="时间" align="center" prop="createTime" />
      <el-table-column label="点击量" align="center" prop="clickCnt" />
      <el-table-column label="下载量" align="center" prop="dowmCnt" />
      <el-table-column label="新增用户" align="center" prop="userAddCnt" />
      <el-table-column label="日活" align="center" prop="activeDayCnt" />
      <el-table-column label="月活" align="center" prop="activeMonthCnt" />
      <el-table-column label="7日留存" align="center" prop="retainLv" />
      <el-table-column label="金币产出" align="center" prop="gold" />
      <el-table-column label="ecpm产出" align="center" prop="ecpm" />
      <el-table-column label="金币提现" align="center" prop="goldWithdraw" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import { listYxsj } from "@/api/agency/money";

export default {
  name: "Yxsj",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 运营数据
      yxsjList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        appName: null,
        companyName: null,
        cjDate: [],
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询总代和代理账户列表 */
    getList() {
      this.loading = true;
      this.addDateRange(this.queryParams, this.queryParams.cjDate,'Cj')
      listYxsj(this.queryParams).then(response => {
        this.yxsjList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    }
  }
};
</script>
